/**
 * Created by Administrator on 15-7-1.
 */
var AccountList = RichBase.extend({
	statics : {},
	EVENTS : {},
	init : function(){
		this.container.on("change",function(e){
			var hash = $(e.currentTarget).val();
			var href = "http://www.12301.cc/module/wechat/special.html?debug=1&hash="+hash;
			window.location.href = href;
		})
	},
	getList : function(){
		var that = this;
		var container = this.container;
		PFT.Ajax({
			url : WXB.URLS.api,
			type : "GET",
			dataType : "JSON",
			ttimeout : WXB.AJAX_TIMEOUT,
			data : { action:"GetWechatBinded"},
			loading : function(){},
			removeLoading : function(res){},
			timeout : function(res){},
			serverError : function(res){}
		},function(res){
			var html = "";
			if(res && res.status == "ok"){
				if(res.list && res.list.length){
					var list = res.list;
					for(var i in list){
						var d = list[i];
						var id = d.id;
						var hash = d.hash;
						var ac_type = d.ac_type;
						var create_time = d.create_time;
						var encodingAESKey = d.encodingAESKey;
						var isconnect = d.isconnect;
						var name = d.name || "默认公众号名称";
						var token = d.token;
						var url = d.url;
						var username = d.username;
						html += '<option value="'+id+'" data-hash="'+id+'" data-actype="'+ac_type+'" data-createtime="'+create_time+'" data-encodingaeskey="'+encodingAESKey+'" data-name="'+name+'" data-username="'+username+'" data-token="'+token+'" data-url="'+url+'">'+name+'</option>';
					}
					container.html(html);
				}else{
					alert("没有公众号");
				}
			}else if(res && res.status == "fail"){
				alert("获取公众号出错");
			}else{
				alert("获取公众号出错");
			}
			setTimeout(function(){
				that.fire("ajax_complete",res);
			},10)
		})
	}
});
